package com.stress.testing.plugin.es.strategy;

import org.elasticsearch.action.search.MultiSearchRequest;
import org.elasticsearch.action.search.SearchRequest;

import java.util.Iterator;
import java.util.List;

public class MultiSearchRequestIndexRenameStrategy extends AbstractRequestIndexRenameStrategy {
    @Override
    public void renameIndex(Object arg) {
        MultiSearchRequest request = (MultiSearchRequest) arg;
        List<SearchRequest> requests = request.requests();
        Iterator<SearchRequest> iterator = requests.iterator();
        while (iterator.hasNext()) {
            SearchRequest req = iterator.next();
            req.indices(internalRenameIndex(req.indices()));
        }
    }
}
